package com.rocsea.robot.model.enums;

import com.rocsea.robot.exception.BusinessException;

import java.util.Objects;

/**
 * @Author RocSea
 * @Date 2022/12/7
 */
public enum KettleBuildStrategyEnum {
    /**
     * 简单
     */
    SIMPLE(1, "simple"),

    /**
     * 第一次走批量插入
     */
    FIRST_BATCH(2, "first_batch"),

    /**
     * 分表按年拆分，轻量的
     */
    SHARDING_ANNUALLY_LIGHT(3, "sharding_annually_light"),

    /**
     * 分表按年拆分，重量的
     */
    SHARDING_ANNUALLY_HEAVY(4, "sharding_annually_heavy"),

    /**
     * 简单去掉updateTimeId
     */
    SIMPLE_REMOVE_UPDATE_TIME_ID(5, "simple_remove_updateTimeId"),

    /**
     * 第一次走批量插入去掉updateTimeId
     */
    FIRST_BATCH_REMOVE_UPDATE_TIME_ID(6, "first_batch_remove_updateTimeId"),

    /**
     * 分页更新
     */
    PAGING_UPDATE(7, "abs_bond_basic_info"),

    /**
     * 主键是UUID
     */
    PK_UUID(8, "t_bond_cred_chan");

    private final Integer value;
    private final String text;

    KettleBuildStrategyEnum(Integer value, String text) {
        this.value = value;
        this.text = text;
    }

    public Integer getValue() {
        return value;
    }

    public String getText() {
        return text;
    }

    public static String geText(Integer value) {
        for (KettleBuildStrategyEnum kettleBuildStrategyEnum : KettleBuildStrategyEnum.values()) {
            if (Objects.equals(kettleBuildStrategyEnum.value, value)) {
                return kettleBuildStrategyEnum.text;
            }
        }
        throw new BusinessException("strategy type not match");
    }
}
